The present invention relates to preprocessing computer source code. More specifically, the invention relates to preprocessing native interface source code.
Java™ is an object-oriented computer programming language. It is most commonly used in Internet applications where Java™ programs are called from within HTML documents. However, Java™ programs can also be launched as stand alone applications.
Before it is executed, Java™ source code is usually translated or compiled into byte code by a Java™ compiler. The byte code is then interpreted or converted to machine language at run time. Java™ can be implemented as an interpreted language, meaning programs written in Java™ can be run using an interpreter. An interpreter translates and runs a program at the same time. Specifically, the interpreter translates one line of programming, executes that line of code, and then proceeds to the next line of code.
The Java™ Virtual Machine (“VM”) carries out the task of interpreting or otherwise executing the Java™ byte code. Java™ VMs are present in most browsers and widely licensed for use in a variety of computing devices. In fact, Java™ VMs are so widely distributed that Java™ is said to offer “write once, run anywhere” portability. With most other programming languages, different versions of a program must be developed for different computer environments. Further, Java™ programs can be stored in relatively small files, which is important in applications where memory is limited (e.g., when running software on cell phones, personal digital assistants, and the like) and makes transmitting the programs over networks easier and faster.
While it is possible to create a computing environment specifically designed for Java™ (e.g., by using a Java™ chip), most Java™ platforms are deployed on top of a non-Java™ host environment that employs a standard processor with a Java™ VM installed in memory. A Java™ platform is a programming environment that includes the Java™ VM and the Java™ application programming interface (“API”). The Java™ API consists of a set of predefined classes.
Java™ also includes a programming interface known as the Java™ Native Interface (“JNI”). The JNI provides a mechanism for calling native platform elements such as graphical user interface (“GUI”) routines and integrating legacy software (existing code written in languages other than Java™) in a Java™ application. As is known, a native application is one specifically designed to run on the computing environment at hand (the operating system and machine language for particular hardware). The JNI allows Java™ elements incorporating or referencing native methods to be written and compiled in such a way that the resulting load object is independent of the Java™ Virtual Machine specifics, and can be used with any virtual machine that supports the JNI for that environment. However, the abstraction that the JNI layer provides to allow load-object independence imposes a performance penalty on both the entry and exit from the native method and also on the activities within the native method, where elements of the Java™ system such as fields, other methods, etc. need to be accessed from the native method.